home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Yerk 3.64 / Supplement / Unsupported / Optionals / 3dArray < prev    next >
Text File  |  1986-01-22  |  1KB  |  62 lines

  1.  \ 3 Dimensional Array
  2. \  1/07/85  cdn Logical extension to 2dArray
  3.  
  4. :CLASS    3dArray     <Super 2dArray  4 <Indexed
  5.  
  6.     Int     xbnd
  7.  
  8.     \ ( xbnd -- )  Store x bound; y & z bound already used by super 2dArray
  9.     :M  CLASSINIT:  classinit: super put: xbnd ;M
  10.  
  11.     \ ( -- )  Allocate arrays for third dimension
  12.     :M  NEW:
  13.         new: super
  14.         ylimit: super 0
  15.         DO
  16.             xlimit: super 0
  17.             DO
  18.                       get: xbnd heap> array i j to: super
  19.             LOOP
  20.         LOOP
  21.     ;M
  22.  
  23.     \ ( val x y z -- )
  24.     :M  TO: to: [ at: super ] ;M
  25.  
  26.     \ ( x y z -- )
  27.     :M  AT: at: [ at: super ] ;M
  28.  
  29.     \ ( -- )  Deallocate array space in heap
  30.     :M  DISPOSE:
  31.         ylimit: super 0
  32.         DO
  33.             xlimit: super 0
  34.             DO
  35.                       i j at: super killptr
  36.             LOOP
  37.         LOOP
  38.         dispose: super
  39.     ;M
  40.  
  41.     :M  XLIMIT: get: xbnd ;M
  42.  
  43.     :M  YLIMIT: xlimit: super ;M
  44.  
  45.     :M  ZLIMIT: ylimit: super ;M
  46.  
  47.     :M  PRINT:  { \ k -- }
  48.                 zlimit: self 0
  49.                 DO  CR ." layer:" i . CR
  50.                     i -> k
  51.                     ylimit: self 0
  52.                     DO  CR
  53.                         xlimit: self 0
  54.                         DO
  55.                             i j k at: self .
  56.                         LOOP
  57.                     LOOP
  58.                 LOOP
  59.     ;M
  60.  
  61. ;CLASS
  62.